package com.example.mythealthapp.users

import android.content.Context
import android.database.sqlite.SQLiteDatabase
import android.database.sqlite.SQLiteOpenHelper
import android.util.Log


class DBHelper(
    context: Context?,
    name:String?,
    version:Int
): SQLiteOpenHelper(context,name,null,version)
{
    val TAG = "@@DBHelper"

    override fun onCreate(db: SQLiteDatabase) {
        Log.d(TAG,"DB onCreating")
        db.execSQL("CREATE TABLE IF NOT EXISTS ${User.TABLE} (\n" +
                "\t${User.U_phone} TEXT PRIMARY KEY,\n" +
                "\t${User.U_name} TEXT,\n" +
                "\t${User.U_pass} TEXT,\n" +
                "\t${User.U_avatar} INTEGER,\n" +
                "\t${User.U_gender} INTEGER,\n" +
                "\t${User.U_addtime} TEXT,\n" +
                "\t${User.U_level} INTEGER)")
    }
    override fun onUpgrade(db: SQLiteDatabase?, oldversion: Int, newversion: Int) {
        Log.d(TAG,"DB on upgrade ,version from $oldversion to $newversion")
    }
}

